﻿#region File Description
/****************************************************************************
*                                                                           *
* Game Manager.                                                             *
*                                                                           *
* Copyright (c) Ionescu Marius. All rights reserved(2013).                  *
*                                                                           *
****************************************************************************/
#endregion
namespace Silverlight3D
{
    using System;
    using System.Windows;
    using System.Windows.Media;
using System.Windows.Controls;

    public abstract class VectorObject : IComparable
    {
        private double brightnessFactor = 1.0;

        public Color FillColor { get; set; }
        public Color StrokeColor { get; set; }

        public double BrightnessFactor
        {
            get { return this.brightnessFactor; }
            set { this.brightnessFactor = value; }
        }

        public double StrokeThickness { get; set; }

        public double CachedMaxZAfterRotation { get; set; }

       
        public abstract double GetMaxZAfterRotation(Projector projector, Vector rotationCenter);

        public abstract Vector Center();

        public abstract UIElement Project(Projector projector, IShader shader, Vector rotationCenter);
        public abstract UIElement Project(Projector projector, IShader shader, Vector viewPosition, Vector rotationCenter);

        public virtual void Draw(Projector projector, Canvas canvas, IShader shader, Vector rotationCenter)
        {
            var element = this.Project(projector, shader, rotationCenter);

            if (element != null)
            {
                canvas.Children.Add(element);
            }
        }

        public virtual void Draw(Projector projector, Canvas canvas, IShader shader, Vector viewPosition, Vector rotationCenter)
        {
            var element = this.Project(projector, shader, viewPosition, rotationCenter);

            if (element != null)
            {
                canvas.Children.Add(element);
            }
        }

        public abstract VectorObject Clone();

        public int CompareTo(object obj)
        {
            var that = (VectorObject)obj;

            return (int)(10000000 * (that.CachedMaxZAfterRotation - this.CachedMaxZAfterRotation));
        }
    }
}
